<?php
$json='{
	"item": [{
		"article_id": "4tQdKshJdH0JvOiAMIPQvCjGucEdMu2A9qAUPVCR45Xy9DlfdYY23MvqLoCNcL4_",
		"content": {
			"news_item": [{
				"thumb_media_id": "2"
			},
			{
				"thumb_media_id": "3"
			}],
			"create_time": 1658369895,
			"update_time": 1658369906
		},
		"update_time": 1658369906
	}, {
		"article_id": "4tQdKshJdH0JvOiAMIPQvBawuX1CNdwvukohpgC5ph_MONahK5xENxsyqq5dZfFT",
		"content": {
			"news_item": [{
				"thumb_media_id": "CZtis-Li_DPXne-Zmds-Yeaizd0tXEbC9SZZzYP9IP2iSRpfrqpQm2SnLOsMLTSu"
			}
			],
			"create_time": 1658369833,
			"update_time": 1658369848
		},
		"update_time": 1658369848
	}, {
		"article_id": "4tQdKshJdH0JvOiAMIPQvP25w6R4TX-w14OdUQQxl_S6R5FVIhMw2m52-Md9AOZt1",
		"content": {
			"news_item": [{
				"content_source_url": "",
				"thumb_media_id": "CZtis-Li_DPXne-Zmds-Yd0RGPF2YV6cciZvD6b1YDBHlXINHetyQWEr7BOazRQi",
				"is_deleted": false
			},{
				"content_source_url": "",
				"thumb_media_id": "CZtis-Li_DPXne-Zmds-Yd0RGPF2YV6cciZvD6b1YDBHlXINHetyQWEr7BOazRQi",
				"is_deleted": false
			}],
			"create_time": 1658369788,
			"update_time": 1658369804
		},
		"update_time": 1658369804
	},{
		"article_id": "4tQdKshJdH0JvOiAMIPQvP25w6R4TX-w14OdUQQxl_S6R5FVIhMw2m52-Md9AOZt2",
		"content": {
			"news_item": [{
				"content_source_url": "",
				"thumb_media_id": "CZtis-Li_DPXne-Zmds-Yd0RGPF2YV6cciZvD6b1YDBHlXINHetyQWEr7BOazRQi",
				"is_deleted": false
			},{
				"content_source_url": "",
				"thumb_media_id": "CZtis-Li_DPXne-Zmds-Yd0RGPF2YV6cciZvD6b1YDBHlXINHetyQWEr7BOazRQi",
				"is_deleted": false
			}],
			"create_time": 1658369781,
			"update_time": 1658369804
		},
		"update_time": 1658369804
	}]
}';
$data=json_decode($json,true);
$data=$data['item'];
$data_copy = $data;

$a=array(
    'id'=>9
);
$thumb_media_id = [];
foreach($data as $key => $value){
    foreach ($value['content']['news_item'] as $key2=>$value2){

//        if(in_array($value2['thumb_media_id'],$thumb_media_id)&&!empty($value2['thumb_media_id'])) {
//            unset($data[$key]['content']['news_item'][$key2]);
//            continue;
//        }
//        var_dump($value2['thumb_media_id']);
//        var_dump($thumb_media_id);
        if(isset($thumb_media_id[$value2['thumb_media_id']])&&!empty($value2['thumb_media_id'])) {
            if($value['content']['create_time']>$thumb_media_id[$value2['thumb_media_id']])
            {
                unset($data[$key]['content']['news_item'][$key2]);
                continue;
            }
        }

//        foreach ($data_copy as $k => $v) {
//            foreach ($v['content']['news_item'] as $k2 => $v2) {
//                if ($value2['thumb_media_id'] == $v2['thumb_media_id']) {
//                    $thumb_media_id[$value2['thumb_media_id']] = $value['content']['create_time'];
//
//                }
//            }
//        }

        foreach($data_copy as $k => $v) {
            foreach ($v['content']['news_item'] as $k2=>$v2){
                if($value2['thumb_media_id']==$v2['thumb_media_id']){
                    $thumb_media_id[] = $value2['thumb_media_id'];
                }
            }
        }
    //    var_dump($thumb_media_id);
    }

}
var_dump($thumb_media_id);
//
//foreach($data as $key => $value){
//    if(empty($data[$key]['content']['news_item'])){
//        unset($data[$key]);
//    }
//}

//echo json_encode($data);

die();